#include"../logs2/bitlog.h"
#include<ustat.h>
#include<vector>
#include<thread>
#include<chrono>
#include<memory>

// void bench(const std::string &Logger_name,size_t thr_count,size_t msg_count,size_t msg_len)
// {
//     HUE::Logger::ptr logger=HUE::getlogger(Logger_name);
//     if(logger.get()==nullptr)
//     {
//         return ;
//     }
//     std::cout<<"测试日志："<<msg_count<<"条，总大小："<<(msg_count*msg_len)/1024<<"KB\n";
//     std::string msg(msg_len-1,'A');
//     std::vector<std::thread> threads;
//     std::vector<double> cost_arry(thr_count);
//     std:: msg_ptr_thr=msg_count/thr_count;
//     for(int i=0;i<thr_count;i++)
//     {
//         threads.emplace_back([&,i]()
//         {
//             auto start=std::chrono::high_resolution_clock::now();
//             for(int j=0;j<msg_ptr_thr;j++)
//             {
//                 logger->fatal("%s",msg.c_str());
//             }
//             auto rnd=std::duration<double> cost=end-start;
//             cost_arry[i]=cost.count();
//             std::cout<<"线程"<<i<<":"<<"\t输出日志数量："<<msg_ptr_thr<<"，耗时："<<cost.count()<<"s"<<std::endl;

//         });
//     }

// }

void test_log(const std::string &name)
{
    INFO("%s","测试开始");
    HUE::Logger::ptr logger=HUE::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s","测试日志");
    logger->info("%s","测试日志");
    logger->warn("%s","测试日志");
    logger->error("%s","测试日志");
    logger->fatal("%s","测试日志");
    INFO("%s","测试完毕");
}
int main()
{
    std::unique_ptr<HUE::LoggerBuilder> builder(new HUE::GlobalLoggerBuilder());
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(HUE::LogLevel::value::DEBUG);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(HUE::LoggerType::LOGGER_SYNC);
    builder->buildSink<HUE::FileSink>("./logfile/async.log");
    builder->buildSink<HUE::StdoutSink>();
    builder->buildSink<HUE::RollSink>("./logfile/roll-async-by-size",1024*1024);
    builder->build();
}

